﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace Business_Layer
{
    [Serializable]
    public class Presentation
    {
        public Presentation()
        {
            initiate();
        }

        private int currentDia;

        private bool headFirst;

        private List<Dia> dias;

        private Bitmap endDia;

        /// <summary>
        /// Initiates a presentation.
        /// </summary>
        private void initiate()
        {
            dias = new List<Dia>();
            endDia = new Bitmap(800, 600);
            
            using (Graphics g = Graphics.FromImage(endDia))
            {
                g.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 0, endDia.Width, endDia.Height));
                g.DrawString("End of presentation.", new Font("Arial", 16), new SolidBrush(Color.White), 10, 10);
                g.DrawString("Press ESCAPE to continue..", new Font("Arial", 8), new SolidBrush(Color.White), 20, 35);
            }

            dias.Add(new Dia(endDia));
            headFirst = true;
        }

        /// <summary>
        /// Adds a new dia to the presentation.
        /// </summary>
        /// <param name="dia"></param>
        public void AddDia(Bitmap dia)
        {
            dias.Insert(dias.Count - 1, new Dia(dia));
        }

        /// <summary>
        /// Sets the current dia to a next dia.
        /// </summary>
        public void NextDia()
        {
            if (headFirst)
            {
                headFirst = false;
                return;
            }
            else
            {
                if (currentDia + 1 < dias.Count) currentDia++;
            }
        }

        /// <summary>
        /// Sets the current dia to a previous dia.
        /// </summary>
        public void PreviousDia()
        {
            if (currentDia - 1 >= 0) currentDia--;
        }

        /// <summary>
        /// Returns the current selected dia.
        /// </summary>
        /// <param name="screen">Screen to draw the dia on.</param>
        /// <returns></returns>
        public Bitmap GetCurrentDia(Bitmap screen)
        {
            return dias.ElementAt(currentDia).Draw(screen);
        }

        /// <summary>
        /// Returns a list with dias.
        /// </summary>
        /// <returns></returns>
        public List<Dia> GetDias()
        {
            return dias;
        }

        /// <summary>
        /// Sets a list with dias.
        /// </summary>
        /// <param name="dias"></param>
        public void SetDias(List<Dia> dias)
        {
            this.dias = dias;
        }
    }
}
